<%@page import="java.util.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<% String path = request.getContextPath();
	String basePath = request.getScheme()+"://" +request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="css/backstyle.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="/js/jquery-1.8.2.js"></script>
	<script type="text/javascript" src="js/getParentType.js"></script>
	<script type="text/javascript">
		$(function (){
			//先获得要修改的商品父类型编号
			var pid = ${requestScope.productType.pid};
			//页面加载时初始化,并获得所有父类别的信息
			initParentType(pid);

			//使用异步提交表单信息
			$("#formData").submit(function (){
				//获得表单的信息
				var formArray = $(this).serializeArray();
				//把表单信息封装
				var updateData = new Object();
				for (var i = 0; i < formArray.length; i++) {
					var name = formArray[i].name;
					var value = formArray[i].value;
					//将数据存放进data对象中
					updateData[name] = value;
				}
				$.ajax({
					url:"ProductTypeController/updateProductType",
					type:"post",
					dataType:"JSON",
					contentType:"application/json",
					data:JSON.stringify(updateData),
					success:function (data){
						if(data.code == 200){
							alert("修改成功！");
							location.href="ProductTypeController/selectPage"
						}else{
							alert("修改失败！")
							location.reload();
						}
					}
				})
				return false;
			});
		})
	</script>
</head>

<body>

	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li><a href="#">首页</a></li>
    <li><a href="#">表单</a></li>
    </ul>
    </div>
    
    <div class="formbody">
    
    <div class="formtitle"><span>修改商品类别信息</span></div>
    <form method="post"  id="formData">
    	<ul class="forminfo">
    	<input type="hidden" name="id" value="${requestScope.productType.id}">
	    <li><label>商品类别名称</label><input name="name" type="text" class="dfinput" value="${requestScope.productType.name}"/><i>标题不能超过30个字符</i></li>
	    	
	    <li><label>父类别</label>
	    		<select name="pid" id="option" >
					<option value="-1">父类</option>
	    		</select>
	    </li>
	    <li><label>&nbsp;</label><input type="submit" class="btn" value="确认保存"/></li>
	    </ul>
    </form>
    </div>


<div style="display:none"><script src='http://v7.cnzz.com/stat.php?id=155540&web_id=155540' language='JavaScript' charset='gb2312'></script></div>
</body>
</html>

